import type {
  AssetLifecycleVo,
  AssetPageRequest,
  AssetPageResponse,
  AssetRelationRequest,
  AssetRelationResponse,
  PageRequest,
  PageResponse,
  ProjectPageRequest,
  ProjectPageResponse,
} from '#/api/kingtown/types';

import { requestClient } from '#/api/request';

export async function pageAssetApi(data: PageRequest<AssetPageRequest>) {
  return requestClient.post<PageResponse<AssetPageResponse>>(
    '/asset/page',
    data,
  );
}

export async function listLifecycleRecordApi(data: string) {
  return requestClient.get<AssetLifecycleVo[]>('/asset/lifecycle', {
    params: { id: data },
  });
}

export async function updateAssetApi(data: AssetPageRequest) {
  return requestClient.post<boolean>('/asset/edit', data);
}

export async function pageProjectApi(data: PageRequest<ProjectPageRequest>) {
  return requestClient.post<PageResponse<ProjectPageResponse>>(
    '/project/page',
    data,
  );
}

export async function pageAssetRelationApi(
  data: PageRequest<AssetRelationRequest>,
) {
  return requestClient.post<PageResponse<AssetRelationResponse>>(
    '/relation/page',
    data,
  );
}
